﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Text;
using System.IO;
using System.Xml;
using BLL;
using DAL;
using Models;
using System.Data;
using Web.Old_App_Code;

public partial class cn_news_center_news_list : System.Web.UI.Page
{

        // Fields
    protected ArticleManager am = new ArticleManager();
    protected string at = "";
    protected ArticleTypeManager atm = new ArticleTypeManager();

    protected string order = "createTime";
    protected int ot = 1;
    protected int pageIndex = 1;
    protected int pageSize = 20;
    protected PageList pl = new PageList();
    protected PageListManager plm = new PageListManager();

    protected int total = 0;

    // Methods
    protected StringBuilder ArticleBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            if (base.Request.QueryString["p"] != null)
            {
                this.pageIndex = Convert.ToInt32(base.Request.QueryString["p"]);
            }
            if (base.Request.QueryString["at"] != null)
            {
                this.at = base.Request.QueryString["at"];
            }
            this.pl.TblName = "view_article";
            this.pl.StrGetFields = "id,articleTilte,typeIdentity,typeName,clickCount,convert(nvarchar(10),createTime,121) as createTime";
            this.pl.FldName = this.order;
            this.pl.PageSize = this.pageSize;
            this.pl.PageIndex = this.pageIndex;
            this.pl.DoCount = 1;
            this.pl.OrderType = this.ot;
            this.pl.StrWhere = "(parentIdStr like '%" + this.at + "%' or atId='" + this.at + "') and languageVersion='zh-CN'";
            this.total = Convert.ToInt32(this.plm.GetPageList(this.pl).Rows[0]["Total"]);
            this.pl.DoCount = 0;
            DataTable pageList = this.plm.GetPageList(this.pl);
            builder.AppendLine("<div class=\"new_class\">");
            builder.AppendLine("<h5><strong>资讯列表</strong></h5>");
            builder.AppendLine("<ul>");
            if (pageList.Rows.Count > 0)
            {
                foreach (DataRow row in pageList.Rows)
                {
                    builder.AppendLine(string.Concat(new object[] { "<li><span class=\"time\">[", row["createTime"], "]</span><strong>[", row["typeName"], "]</strong><a href=\"news_detail.html?id=", row["id"], "\">", row["articleTilte"], "</a></li>" }));
                }
            }
            else
            {
                builder.AppendLine("<li>没有找到任务记录！</li>");
            }
            builder.AppendLine("<ul>");
            builder.AppendLine("</div>");
            builder.AppendLine(new PageListNo().FrontDeskDisplayPage(this.total, this.pageSize, this.pageIndex).ToString());
        }
        catch
        {
        }
        return builder;
    }

    protected StringBuilder ArticleTypeBind()
    {
        StringBuilder builder = new StringBuilder();
        try
        {
            this.at = this.atm.GetArticleTypeByTypeNameAndParentIdAndLanguageVersion("资讯中心", "00000000-0000-0000-0000-000000000000", "zh-CN");
            builder.AppendLine("<dl>");
            DataTable articleTypeByParentTypeAndLanguageVersion = this.atm.GetArticleTypeByParentTypeAndLanguageVersion(this.at, "zh-CN");
            foreach (DataRow row in articleTypeByParentTypeAndLanguageVersion.Rows)
            {
                builder.AppendLine(string.Concat(new object[] { "<dt><strong><a href=\"?at=", row["id"], "\">", row["typeName"], "</a></strong></dt>" }));
                DataTable table2 = this.atm.GetArticleTypeByParentTypeAndLanguageVersion(row["id"].ToString(), "zh-CN");
                foreach (DataRow row2 in table2.Rows)
                {
                    builder.AppendLine(string.Concat(new object[] { "<dd><a href=\"?at=", row2["id"], "\">", row2["typeName"], "</a></dd>" }));
                }
            }
            builder.AppendLine("</dl>");
        }
        catch
        {
        }
        return builder;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
    }


}